#!/bin/sh
set -e

case "$1" in
    remove)

	if [ -e /boot/grub/grub.cfg ]; then
		# Will break Live CD generation, LP #1228462
		update-grub || true
	fi

	if which update-initramfs >/dev/null 2>&1
	then
	    update-initramfs -u
	fi
	;;

    purge)
	;;

    upgrade|failed-upgrade|disappear)
	;;

    abort-install|abort-upgrade)
	;;

    *)
	echo "$0 called with unknown argument \`$1'" 1>&2
	exit 1
	;;
esac

#DEBHELPER#
update-alternatives --remove-all default.plymouth
update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/openkylin-logo/openkylin-logo.plymouth 150

file_path='/usr/share/grub/themes/UKUI/theme.txt'
line_number=$(grep -n 'desktop-image:' $file_path | cut -d ':' -f 1)

if [ -n $line_number ]; then
  sed -i '/^desktop-image:/s|".*"|"'background.png'"|' "$file_path"
fi
